'use strict';

/**
 * @ngdoc service
 * @name jgappApp.appVersion
 * @description
 * # appVersion
 * Service in the jgappApp.
 */
angular.module('jgappApp')
    .service('appVersion', ["$http", "openApi", '$q', function($http, openApi, $q) {
        // AngularJS will instantiate a singleton by calling "new" on this function
        var appVersion = {}
        appVersion.getAppVersion = function() {
            var param = {}
            param.noloader = true
            var delay = $q.defer();
            $http.get("config/appVersion.json", param)
                .success(function(data) {
                    console.log(data)
                    delay.resolve(data);
                });
            return delay.promise;
        }
        appVersion.checkAppVersion = function(param) {
            param.noloader = true
            var delay = $q.defer();
            $http.post(openApi.getAppVersion, param)
                .success(function(data) {
                    console.log(data)
                    delay.resolve(data);
                }).error(function() {
                    delay.reject("获取版本号信息出错");
                });
            return delay.promise;
        }
        return appVersion
    }]);
